package com.kk.netty.basice.demo2;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;

public class HandlerAndPipeline {
    public static void main(String[] args) {
        new ServerBootstrap ()
                .group (new NioEventLoopGroup ())
                .channel (NioServerSocketChannel.class)
                .childHandler (new ChannelInitializer<NioSocketChannel> ( ) {
                    @Override
                    protected void initChannel(NioSocketChannel ch) {
                        // 1、
                        ch.pipeline ().addLast (new ChannelInboundHandlerAdapter (){
                            @Override
                            public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
                                ctx.fireChannelRead (msg);
                            }
                        });
                    }
                });
    }
}
